<?php
namespace app\unit\controller;

use Flc\Alidayu\Client;
use Flc\Alidayu\App;
use Flc\Alidayu\Requests\AlibabaAliqinFcSmsNumSend;

class Message
{
    public $client;
    public $req;

    function __construct()
    {
        $this->client = new Client(new App(config('alidayu')));
        $this->req = new AlibabaAliqinFcSmsNumSend;
        $this->req->setSmsFreeSignName('自家菜园');
    }

    public function pickup($number, $name, $address)
    {
        $this->req
            ->setSmsTemplateCode('SMS_53205290')
            ->setRecNum($number)
            ->setSmsParam([
                'username' => $name,
                'address' => $address
            ]);
        return $this->client->execute($this->req);
    }

    public function send()
    {
        $this->req->setRecNum('15640380127')
            ->setSmsParam([
                'username' => '蒋佳林',
                'address' => '自家菜园'
            ])
            ->setSmsFreeSignName('自家菜园')
            ->setSmsTemplateCode('SMS_53205290');

        $res = $this->client->execute($this->req);
        print_r($res);
        return 'DONE';
    }
}
